;;; common.el --- 所有模栻下基本都會用到的配置

;; 設置文件默認編碼
(setq default-buffer-file-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;; 設置字體
(when window-system
  (progn
    (set-face-attribute 'default nil :font "Monaco 12")
    (dolist (charset '(kana han symbol cjk-misc bopomofo))
      (set-fontset-font (frame-parameter nil 'font)
			charset
			(font-spec :family "PingFang SC" :size 14)))))
;; Remap keys
(setq mac-command-modifier 'meta)
(setq mac-control-modifier 'control)
(setq mac-option-modifier 'alt)
(global-set-key [kp-delete] 'delete-char)
(setq mac-function-modifier 'control)

;; 啟動時的大小和位置
(setq default-frame-alist
      '((height . 35)(width . 100)(menubar-lines . 20)(tool-bar-lines . 0)))

;; 取消滾動欄，工具欄
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)

;; 以y/n代表yes/no
(fset 'yes-or-no-p 'y-or-n-p)

;; 備份設置
(setq make-backup-files t)
(setq kept-old-versions 2)
(setq kept-new-versions 2)
(setq delete-old-versions t)
(setq backup-directory-alist '(("" . "~/.emacsbackup")))

;; -----------------------------------------------------
;; autopair
(autopair-global-mode)

;; -----------------------------------------------------
;; yasnippet
(require 'yasnippet)
(yas-global-mode 1)

;; ------------------------------------------------------
;; company
(add-hook 'after-init-hook 'global-company-mode)

;; ------------------------------------------------------
;; iedit
(define-key global-map (kbd "C-c ;") 'iedit-mode)

;; -----------------------------------------------------
;; flycheck
(add-hook 'after-init-hook #'global-flycheck-mode)
(add-hook 'flycheck-mode-hook
          (lambda ()
            (setq flycheck-check-syntax-automatically
                  '(idle-change save  mode-enabled))
            (setq flycheck-idle-change-delay 2)))


;;; common.el ends here
